/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package datos;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Ing. Monica Merlo, Ing. Agustin  Fernandez
 */
@Entity
@Table(name = "pago")
@NamedQueries({@NamedQuery(name = "Pago.encontrarPagosPorCertificado", query = "SELECT p FROM Pago p WHERE p.idCertificado.id = :idCertificado"),
@NamedQuery(name = "Pago.calcularSaldo", query = "SELECT SUM(p.monto) FROM Pago p WHERE p.idCertificado.id = :idCertificado"),
@NamedQuery(name = "Pago.encontrarPorObra", query = "SELECT p FROM Pago p WHERE p.idCertificado.idObra.id = :idObra AND p.idCertificado.idObra.eliminada = 0 "),
@NamedQuery(name = "Pago.findAll", query = "SELECT p FROM Pago p"), @NamedQuery(name = "Pago.findById", query = "SELECT p FROM Pago p WHERE p.id = :id"),
@NamedQuery(name = "Pago.findByNumero", query = "SELECT p FROM Pago p WHERE p.numero = :numero"),
@NamedQuery(name = "Pago.findByFecha", query = "SELECT p FROM Pago p WHERE p.fecha = :fecha"),
@NamedQuery(name = "Pago.findByMonto", query = "SELECT p FROM Pago p WHERE p.monto = :monto"),
@NamedQuery(name = "Pago.findByNumeroCheque", query = "SELECT p FROM Pago p WHERE p.numeroCheque = :numeroCheque"),
@NamedQuery(name = "Pago.findByTipoCheque", query = "SELECT p FROM Pago p WHERE p.tipoCheque = :tipoCheque"),
@NamedQuery(name = "Pago.findByEmisor", query = "SELECT p FROM Pago p WHERE p.emisor = :emisor"),
@NamedQuery(name = "Pago.findByBanco", query = "SELECT p FROM Pago p WHERE p.banco = :banco"),
@NamedQuery(name = "Pago.findByNroSucursal", query = "SELECT p FROM Pago p WHERE p.nroSucursal = :nroSucursal")})
public class Pago implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "numero")
    private int numero;
    @Basic(optional = false)
    @Column(name = "fecha")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    @Basic(optional = false)
    @Column(name = "monto")
    private BigDecimal monto;
    @Lob
    @Column(name = "observaciones")
    private String observaciones;
    @Column(name = "numeroCheque")
    private Integer numeroCheque;
    @Column(name = "tipoCheque")
    private String tipoCheque;
    @Column(name = "emisor")
    private String emisor;
    @Lob
    @Column(name = "numeroCtaCorriente")
    private String numeroCtaCorriente;
    @Column(name = "banco")
    private String banco;
     @Column(name = "nroSucursal")
    private Integer nroSucursal;
    @JoinColumn(name = "idCertificado", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Certificado idCertificado;

    public Pago() {
    }

    public Pago(Integer id) {
        this.id = id;
    }

    public Pago(Integer id, int numero, Date fecha, BigDecimal monto) {
        this.id = id;
        this.numero = numero;
        this.fecha = fecha;
        this.monto = monto;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getNumero() {
        return numero;
    }

    public void setNumero(int numero) {
        this.numero = numero;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public BigDecimal getMonto() {
        return monto;
    }

    public void setMonto(BigDecimal monto) {
        this.monto = monto;
    }

    public String getObservaciones() {
        return observaciones;
    }

    public void setObservaciones(String observaciones) {
        this.observaciones = observaciones;
    }

    public Integer getNumeroCheque() {
        return numeroCheque;
    }

    public void setNumeroCheque(Integer numeroCheque) {
        this.numeroCheque = numeroCheque;
    }

    public String getTipoCheque() {
        return tipoCheque;
    }

    public void setTipoCheque(String tipoCheque) {
        this.tipoCheque = tipoCheque;
    }

    public String getEmisor() {
        return emisor;
    }

    public void setEmisor(String emisor) {
        this.emisor = emisor;
    }

    public String getNumeroCtaCorriente() {
        return numeroCtaCorriente;
    }

    public void setNumeroCtaCorriente(String numeroCtaCorriente) {
        this.numeroCtaCorriente = numeroCtaCorriente;
    }

    public String getBanco() {
        return banco;
    }

    public void setBanco(String banco) {
        this.banco = banco;
    }

    public Certificado getIdCertificado() {
        return idCertificado;
    }

    public void setIdCertificado(Certificado idCertificado) {
        this.idCertificado = idCertificado;
    }

    /**
     * @return the nroSucursal
     */
    public Integer getNroSucursal() {
        return nroSucursal;
    }

    /**
     * @param nroSucursal the nroSucursal to set
     */
    public void setNroSucursal(Integer nroSucursal) {
        this.nroSucursal = nroSucursal;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pago)) {
            return false;
        }
        Pago other = (Pago) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "datos.Pago[id=" + id + "]";
    }



}